package risk.client.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Image;
import java.awt.LayoutManager;

import java.awt.Toolkit;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.event.*;

import java.awt.image.BufferedImage;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import javax.swing.JTextArea;

import javax.swing.border.Border;

import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;

import risk.client.Risk;
import risk.client.logic.GameManager;

/**
 *
 * @author: Mike
 */
public class SplashDialog extends JFrame {
  // Variables declaration - do not modify
  private JButton button1;
  private JButton button2;
  private java.awt.Label label1;
  
  private int choice = -1;
  ImageIcon bgImage = new ImageIcon(GameBoard.IMG_PATH + "splash.png");
  
  // End of variables declaration
    
  /** Creates new form GameDialog */
      public SplashDialog() {
      
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        this.setLocation(screenWidth / 4, screenHeight / 4);
        this.setSize(570, 375);
        this.getContentPane().setBackground(Color.BLACK);
      
        GameDialog();
      }
      
      
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">
      private void GameDialog() {
          button1 = new JButton("NewGame");
          button2 = new JButton("Mapeditor");
          label1 = new java.awt.Label();
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

          button1.setActionCommand("NewGame");
          //button1.setLabel("New Game");
          button1.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  button1ActionPerformed(evt);
              }
          });

          button2.setActionCommand("MapEdit");
          //button2.setLabel("Mapeditor");
          button2.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  button2ActionPerformed(evt);
              }
          });

/*
          Border line = new LineBorder(Color.BLACK);
          Border margin = new EmptyBorder(5, 15, 5, 15);
          Border compound = new CompoundBorder(line, margin);
          button1.setBorder(compound);
          */

          label1.setAlignment(java.awt.Label.CENTER);
          label1.setFont(new java.awt.Font("Broadway", 0, 24)); // NOI18N
          label1.setVisible(false);

          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addGap(180, 180, 180)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                      .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                      .addGroup(layout.createSequentialGroup()
                          .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                          .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                  .addContainerGap(84, Short.MAX_VALUE))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                  .addGap(27, 27, 27)
                  .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                      .addComponent(button2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                      .addComponent(button1, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE))
                  .addGap(8, 8, 8))
          );

          //pack();
      }// </editor-fold>
      
    /**
     * @author: Pierre
     * @return choice
     */
    public int getChoice() {
        return choice;
    }
    
    /**
     * @author: Pierre
     */
    public void unsetChoice() {
        choice = -1;
    }
    
    /**
     * @author: Pierre
     * @param evt
     */
    private void button2ActionPerformed(java.awt.event.ActionEvent evt) {
        choice = 1;
        this.dispose();
    }
    
    /**
     * @author: Pierre
     * @param evt
     */
    private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
        choice = 0;
        this.dispose();
    }
    
    
  public void paint(Graphics g) {
    super.paint(g);
    g.drawImage(bgImage.getImage(), 0, 20, this);
  }
}

    
